package com.haojiu.service;

import com.github.pagehelper.PageHelper;
import com.haojiu.mapper.BookMapper;
import com.haojiu.pojo.Book;

import java.util.List;

/**
 * @author:我叫浩九
 * @date：2021/8/24 19:15
 * create in RuGao JiangSu
 */
public class BookServiceImpl implements BookService {

    //调用dao层的操作，设置一个set接口，方便Spring管理
    private BookMapper bookMapper;

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    public int addBook(Book book) {
        return bookMapper.addBook(book);
    }

    public int deleteBookById(int id) {
        return bookMapper.deleteBookById(id);
    }

    public int updateBook(Book books) {
        return bookMapper.updateBook(books);
    }

    public Book queryBookById(int id) {
        return bookMapper.queryBookById(id);
    }

    @Override
    public  Book queryBookByName(String bookName) {
        return bookMapper.queryBookByName(bookName);
    }

    @Override
    public List<Book> queryBookByAuthor(String author) {
        return bookMapper.queryBookByAuthor(author);
    }

    public List<Book> queryAllBook(int page,int size) {
        PageHelper.startPage(page,size);
        return bookMapper.queryAllBook();
    }

    @Override
    public List<Book> queryAllBook() {
        return bookMapper.queryAllBook();
    }

    @Override
    public List<Book> getBookCountByType() {
        return bookMapper.getBookCountByType();
    }
}
